package com.example.wechat_applet.controller;

import com.example.wechat_applet.pojo.Result;
import com.example.wechat_applet.pojo.User;
import com.example.wechat_applet.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("user")
public class UserController
{
	@GetMapping("/ok")
	@ResponseBody
	public Result ok()
	{
		return Result.ok();
	}

	@GetMapping("/error")
	@ResponseBody
	public Result error()
	{
		return Result.error();
	}
	@Autowired
	private LoginService loginService;
	
	@GetMapping("/login")
	@ResponseBody
	public Result login(@RequestParam("name")String name,@RequestParam("password")String password)
	{
		User user = new User();
		user.setName(name);
		user.setPassword(password);
		return loginService.login(user);
	}	
}
